<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@page   import= "cn.beans.*"%> 
<%@page   import= "java.util.*"%> 

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="<%=basePath%>admin/css/global.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath%>admin/css/page.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath%>admin/css/form.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath%>admin/css/style.css" />
		<link rel="stylesheet" type="text/css"	href="<%=basePath%>admin/css/dialog.css" />
		<title></title>
	</head>
	<body>
   	<div class="wapper show">
		<h2 class="pagerTitle tabTitle" ><a class="tab tabActive">修改产品</a></h2>
		<form id="productform" name="productform" enctype="multipart/form-data" method="post" action="updateProduct.action">
		<div class="inputLabelParent">
			
			<div class="inputLabel">
			<label class="left">产品分类:</label>
				<select id="productCategory" name="pcId"></select>
			</div>
			<%--<div class="inputLabel">
			<label class="left">产品分类:</label>
			--%><input type="hidden" value="${product.brand}" name="product.brand" id="brand" class="text" style="width:300px;" maxlength="50"><span class="tips" id="branderror"><%--
			* 必填</span>
			</div>
			--%>
			
			<!-- 
			<div class="inputLabel">
				<label class="left">产品类别:</label><input type="text" name="product.productid" id="productid" class="text" style="width:300px;" maxlength="50" value="${product.productid }" ><span class="tips" id="introductionerror">* 必填</span>
			</div> 
			-->
			<input type="hidden" value="1" name="product.productid" id="productid" class="text"  style="width:300px;" maxlength="50"><span class="tips" id="introductionerror">
			
			<div class="inputLabel">
			<input type="hidden" name="productId" id="id" value="${product.id}"/>
			<input type="hidden" name="catagoryId" id="catagoryId" value="${product.category.id}"/>
			<label class="left">产品名称:</label><input type="text" name="product.title" id="title" class="text" style="width:300px;" maxlength="50" value="${product.title}"><span class="tips" id="titleerror">* 必填，50字以内</span>
			</div>
			
			<div class="inputLabel">
			<label class="left">价格:</label><input type="text" value="${product.price}" name="price" id="price" class="text" style="width:300px;" maxlength="50" onkeypress="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value" onkeyup="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value" onafterpaste="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/))this.value=this.t_value;else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value"><span class="tips" id="priceerror">* 必填</span>
			</div>
			<div class="inputLabel">
			<label class="left">尺寸:</label><input type="text" name="product.productsize" id="productsize" class="text" style="width:300px;" maxlength="50" value="${product.productsize }" >
			<span class="tips" id="titleerror">* 可以多填，用英文的小写逗号“,”分隔</span>
			</div>
			<div class="inputLabel">
			<label class="left">款式:</label><input type="text" name="product.bspecification" id="bspecification" class="text" style="width:300px;" maxlength="50" value="${product.bspecification }" >
			<span class="tips" id="titleerror">* 可以多填，用英文的小写逗号“,”分隔</span>
			</div>
			<div class="inputLabel">
			<label class="left">颜色:</label><input type="text" value="${product.color}" name="product.color" id="color" class="text" style="width:300px;" maxlength="100">
			<span class="tips" id="titleerror">* 可以多填，用英文的小写逗号“,”分隔</span>
			</div>
			<div class="inputLabel">
			<label class="left">标签:</label><input type="text" name="product.standard" id="standard" class="text" style="width:300px;" maxlength="50" value="${product.standard }" >
			<span class="tips" id="titleerror">* 可以多填，用英文的小写逗号“,”分隔</span>
			</div>
			<s:iterator value="listProductFile" id="list">
				<s:if test="#list.mainPic == 1">
					<div class="inputLabel">
						<label class="left" id="indexPic">主图片(175*175):</label>
						<s:file cssClass="picF" name="picF" cssStyle="display:none;"  id="picF" /><div class="picDiv"><a href="<%=basePath%>upload/product/<s:property value="#list.saveName"/> " target="_blank"><s:property value="#list.name" /></a>&nbsp;<a class="deleteFile" id="<s:property value="#list.id"/> " href="#">删除</a></div>
					</div>
				</s:if >
			</s:iterator>
			<s:iterator value="listProductFile" id="list">
				<s:if test="#list.mainPic == 0">
					<div class="inputLabel">
						<label class="left" id="indexPic" >产品图片(450*450):</label>
						<s:file cssClass="pic" name="pic" cssStyle="display:none;" /><div class="picDiv"><a href="<%=basePath%>upload/product/<s:property value="#list.saveName"/> " target="_blank"><s:property value="#list.name" /></a>&nbsp;<a class="deleteFile" id="<s:property value="#list.id"/> " href="#">删除</a></div>
					</div>
				</s:if>
			</s:iterator>
			<div class="inputLabel" id="hot">
			<label class="left">是否热销产品:</label>
			<input type="radio" name="product.isHot" id="hot" value="0" <s:if test='product.isHot=="0"'>checked='checked'</s:if> /> 
			<label style="width:20px;">否</label>
			<input type="radio" name="product.isHot" id="hot" value="1" <s:if test='product.isHot=="1"'>checked='checked'</s:if>  /> 
			<label style="width:20px;">是</label>
			</div>
			<%--<div class="inputLabel">
			<label class="left">供货时间:</label>--%>
			<input type="hidden" value="${product.days}" name="product.days" id="days" class="text" style="width:300px;" maxlength="50" ><span class="tips" id="introductionerror"><%--
			<%--* 必填</span>
			</div>
			--%>
			
			<div class="inputLabel">
			<label class="left">淘宝链接:</label><input type="text" value="${product.material}" name="product.material" id="material" class="text" style="width:300px;" maxlength="500">
			</div>
			
			<div class="inputLabel heightauto">
			<label class="left">产品介绍: </label><textarea name="product.content">${product.content}</textarea><span class="tips" id="introductionerror">* 必填</span>
			</div>
			<div style="clear:both; padding-left:500px;">
			<div class="submit submitFloat"><input type="button" id="updateNews" value="保存" />&nbsp;<input type="button" id="returnNews" value="返回" /> 
			</div>
			</div>
			<%--<div class="inputLabel">
			<label class="left">包装规格:</label><input type="text" name="product.specification" id="specification" class="text" style="width:300px;" maxlength="50" value="${product.specification }" >
			</div>
			<div class="inputLabel">
			<label class="left">材质:</label><input type="text" value="${product.material}" name="product.material" id="material" class="text" style="width:300px;" maxlength="500">
			</div>
			<div class="inputLabel">
			<label class="left">是否新产品:</label>
			<input type="radio" name="product.isNew" id="hot" value="0" <s:if test='product.isNew=="0"'>checked='checked'</s:if> /> <label style="width:20px;">否</label>
			<input type="radio" name="product.isNew" id="hot" value="1"  <s:if test='product.isNew=="1"'>checked='checked'</s:if>  /> <label style="width:20px;">是</label>
			</div>
			<%--<div class="inputLabel heightauto">
			<label class="left">产品简介:</label><textarea name="product.introduction" wrap="physical" id="introduction" style="width: 300px">${product.introduction}</textarea>
			</div>
			<div class="inputLabel">
			<label class="left">重量:</label><input type="text" value="${product.weight}" name="product.weight" id="weight" class="text" style="width:300px;" maxlength="100">
			</div>
			<div class="inputLabel">
			<label class="left">是否推销产品:</label>
			<input type="radio" name="product.ispromote" id="ispromote" value="0"  <s:if test='product.ispromote=="0"'>checked='checked'</s:if> /> <label style="width:20px;">否</label>
			<input type="radio" name="product.ispromote" id="ispromote" value="1"  <s:if test='product.ispromote=="1"'>checked='checked'</s:if> /> <label style="width:20px;">是</label>
			</div>

			<div class="inputLabel">
			<label class="left">库存状态:</label>
			<input type="radio" name="product.offertime" id="offertime" value="0" <s:if test='product.offertime=="0"'>checked='checked'</s:if> /> <label style="width:70px;">15天之内</label>
			<input type="radio" name="product.offertime" id="offertime" value="1" <s:if test='product.offertime=="1"'>checked='checked'</s:if> /> <label style="width:70px;">15天之后</label>
			</div>--%>

			
			<!-- PV -->
			<input type="hidden" value="<s:property value="product.pv"/>"></input>			
		</div>
		</form>
		<input type="hidden" id="errorinfo" value="${errorinfo}" />
   	</div>
   
   
   		<script type="text/javascript" src="<%=basePath%>admin/js/jquery.js"></script>
		<script type="text/javascript" src="<%=basePath%>admin/js/jqueryui.js"></script>
		<script type="text/javascript" src="<%=basePath%>admin/js/simpleDialog.js"></script>
		<script type="text/javascript" src="<%=basePath%>admin/js/simplePage.js"></script>
		<script type="text/javascript" src="<%=basePath%>admin/product/js/checkForm.js"></script>
		<script type="text/javascript" src="<%=basePath%>admin/fckeditor/fckeditor.js"> </script> 
   		<script language="JavaScript" type="text/javascript" charset="utf-8">
    		window.onload = function() { 
    		var oFCKeditor = new FCKeditor( 'product.content' ) ; 
    		oFCKeditor.BasePath = '<%=basePath%>admin/fckeditor/';        
    		oFCKeditor.Height = 450 ;       
   			oFCKeditor.Width = 630 ;        
			oFCKeditor.ToolbarSet = 'Default';
			oFCKeditor.Config["CustomConfigurationsPath"]="<%=basePath%>admin/fckeditor/myconfig.js";
			oFCKeditor.ReplaceTextarea();
    	}

    	var m = 1;
    	$(function(){
    		<% if(null!=request.getAttribute("listProductFile")){
    			List list = (List)request.getAttribute("listProductFile");
    			for(int i = 0;i<list.size();i++){
    				ProductFile p = (ProductFile)list.get(i);
    				String mainPic = p.getMainPic();
    		%>
    		<%		
    				if("1".equals(mainPic)){
    		%>
						m = 0;
    		<%			
    				}
    			}
    		}
    		%>
			
    		var length=$('div.inputLabel').find('input[type="file"]').length;

    		var string='<div class="inputLabel"><label class="left" id="indexPic">产品图片:</label><input type="file" name="pic"/></div>';
    		
    		var string_mainPic='<div class="inputLabel"><label class="left" id="indexPic">主图片:</label><input type="file" name="picF" id="#picF" value="123" /></div>';
    		for(var i=length;i<5;i++){
        		if(m == 1){
        			$('#hot').before(string_mainPic);
					m = 0;
            	}else{
            		$('#hot').before(string);
                }
    		}
    		
    	});
	</script> 
   
  </body>
</html>
